package com.study.consumer.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.study.consumer.dto.UserInfoDto;
import com.study.consumer.service.UserInfoAccess;
import com.study.consumer.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author anner
 * @description: TODO
 * @date 2021/4/18 22:08
 */
@Service
@Slf4j
public class UserInfoAccessImpl implements UserInfoAccess {

    @Autowired
    private RedisUtil redisUtil;

    /**
     * 获取用户信息
     * @return
     */
    public Object getUserInfoDemo() {
        String redisKey = "liyy";
        Object userInfo = redisUtil.get(redisKey);
        log.info("用户信息 redisKey:{}, value:{}", redisKey, userInfo);
        JSONObject userInfoJson = (JSONObject) userInfo;
//        UserInfoDto userInfoDto = (UserInfoDto) userInfo;
        log.info("userInfoJson:{}", userInfoJson);
        return userInfo;
    }

}
